import React from 'react';
import FileUpload from './FileUpload.jsx';

class FileUploader extends React.Component{
    render(){
        const options={
            baseUrl:'/manage/product/upload.do',
            fileFieldName:'upload_file',
            chooseAndUpload:true,
            dataType:'json',
            uploadSuccess:(res)=> {
                this.props.onSuccess(res.data);
            },
            uploadError:(err)=>{
                this.props.onError(err || '请上传图片')
            }
        }
        return (
            <FileUpload options={options}>
                <button ref='chooseAndUpload'>请选择图片</button>
            </FileUpload>
        )
    }
}

export default FileUploader;